package com.ruoyi.system.service.congyuhui.impl;

import java.util.List;

import com.ruoyi.system.domain.chongyuhui.TbOrderEntity;
import com.ruoyi.system.mapper.chongyuhui.TbOrderMapper;
import com.ruoyi.system.service.congyuhui.TbOrderService;
import org.apache.ibatis.session.ExecutorType;
import org.apache.ibatis.session.SqlSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import org.apache.ibatis.session.SqlSessionFactory;

/**
 * (TbOrder)表服务实现类
 *
 * @author makejava
 * @since 2024-05-29 23:07:23
 */
@Service
public class TbOrderServiceImpl implements TbOrderService {

    @Autowired
    private TbOrderMapper tbOrderMapper;

    @Resource
    private SqlSessionFactory sqlSessionFactory;

    /**
     * 新增
     */
    @Override
    public void insert(TbOrderEntity tbOrderEntity) {
        tbOrderMapper .insert(tbOrderEntity);
    }

    /**
     * 批量新增
     */
    @Override
    public void batchInsert(List<TbOrderEntity> tbOrderEntities) {
        SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH,false);
        TbOrderMapper mapper = sqlSession.getMapper(TbOrderMapper .class);
        tbOrderEntities .stream().forEach(tbOrderEntity -> mapper.insert(tbOrderEntity));
        sqlSession.commit();
        sqlSession.clearCache();
    }


    /**
     * 刪除
     */
    @Override
    public void delete(TbOrderEntity tbOrderEntity) {
        tbOrderMapper .delete(tbOrderEntity);
    }

    /**
     * 批量刪除
     */
    @Override
    public void batchDelete(List<TbOrderEntity> tbOrderEntities) {
        tbOrderMapper .batchDelete(tbOrderEntities);
    }

    /**
     * 编辑
     */
    @Override
    public void update(TbOrderEntity tbOrderEntity) {
        tbOrderMapper .update(tbOrderEntity);
    }

    /**
     * 批量编辑
     */
    @Override
    public void batchUpdate(List<TbOrderEntity> tbOrderEntities) {
        tbOrderMapper .batchUpdate(tbOrderEntities);
    }


    /**
     * 查询
     */
    @Override
    public List<TbOrderEntity> query(TbOrderEntity tbOrderEntity) {
        List<TbOrderEntity> result = tbOrderMapper .select(tbOrderEntity);
        return result;
    }


}

